//
//  SkillAccessoryView.m
//  EVETracker
//
//  Created by Scott A. Guyer on 8/8/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "SkillAccessoryView.h"
#import "defs.h"


@implementation SkillAccessoryView

@synthesize label, rectFillColor;


- (id)initWithFrame:(CGRect)frame {
	if (self = [super initWithFrame:frame]) {
		// Initialization code
	}
	return self;
}


- (void)drawRect:(CGRect)rect 
{
	// Drawing code
	CGContextRef cgc = UIGraphicsGetCurrentContext();
	
	CGContextSetFillColorWithColor( cgc, rectFillColor.CGColor);
	CGContextFillRect( cgc, rect);
	
	CGContextSetRGBFillColor( cgc, 1.0, 1.0, 1.0, 1.0);
	CGContextFillEllipseInRect( cgc, rect);

	CGContextSetFillColorWithColor( cgc, rectFillColor.CGColor);
	CGContextSetStrokeColorWithColor( cgc, rectFillColor.CGColor);
    CGContextSelectFont( cgc, "Helvetica", 16.0, kCGEncodingMacRoman);
    CGAffineTransform xform = CGAffineTransformMake(
													1.0,  0.0,
													0.0, -1.0,
													0.0,  0.0);
    CGContextSetTextMatrix( cgc, xform);
	CGContextSetTextDrawingMode( cgc, kCGTextInvisible);
	CGContextShowTextAtPoint( cgc, 0, 0, [label cStringUsingEncoding:NSASCIIStringEncoding], label.length);
	CGPoint endpos = CGContextGetTextPosition( cgc);
	
	float left = (rect.size.width - endpos.x) / 2.0 ;
	
	CGContextSetTextDrawingMode( cgc, kCGTextFillStroke);
	CGContextShowTextAtPoint( cgc, left, 16.0, [label cStringUsingEncoding:NSASCIIStringEncoding], [label length]);
}


- (void)dealloc {
	NSLog(@"%s 0x%x", __FUNCTION__, self);
	
	WIPE( label)
	WIPE( rectFillColor)
	
	[super dealloc];
}


@end
